package com.zmn.plat.common.dictionary;

/**
 * 渠道收款限制
 *
 * @author xiangjunming
 * @since 2020/03/26 14:56:30
 */
public enum ChannelReceivablesLimitEnum {

    /**
     * values
     */
    XDYF(ChannelReceivablesLimitEnum.CONSTS_XDYF, "下单预付全款"),
    GCS(ChannelReceivablesLimitEnum.CONSTS_GCS, "工程师收全款"),
    YFWK(ChannelReceivablesLimitEnum.CONSTS_YFWK, "预付+尾款"),
    HF(ChannelReceivablesLimitEnum.CONSTS_HF, "后付费"),
    ;

    /**
     * 下单预付全款
     */
    public final static int CONSTS_XDYF = 1;
    /**
     * 工程师收全款
     */
    public final static int CONSTS_GCS = 2;
    /**
     * 预付+尾款
     */
    public final static int CONSTS_YFWK = 3;
    /**
     * 后付费
     */
    public final static int CONSTS_HF = 4;

    private Integer code;
    private String name;

    ChannelReceivablesLimitEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static ChannelReceivablesLimitEnum of(Integer code) {
        if (code == null) {
            return null;
        }
        switch (code) {
            case 1:
                return XDYF;
            case 2:
                return GCS;
            case 3:
                return YFWK;
            case 4:
                return HF;
            default:
                return null;
        }
    }

    public static String getName(Integer code) {
        ChannelReceivablesLimitEnum of = of(code);
        return of == null ? null : of.getName();
    }
}
